<template>
  <div class="content">
    <Tools
        :data="[{id:1,template:'<span>我的</span><span>消息</span>',url:''}]"></Tools>
    <div class="top-info-block">
      <div class="info-content">
        <img :src="detail.logoUrl" class="company-photo" alt="" v-if="detail.logoUrl">
        <img src="@/assets/images/company_default.png" class="company-photo" alt="" v-else>
        <div class="info-block">
          <div class="name-block">
            <div class="name">{{detail.enterpriseName}}</div>
            <div class="attention-btn" @click="addLookMe" v-if="detail.follow===0">关注</div>
            <div class="btn3 attention-btn" @click="insertLookMe" v-if="detail.follow===1" style="border: 1px solid #ff7626;background: none; color: #ff7626">已关注</div>
          </div>
          <div class="authentication">
            <div class="authenticate"><i class="el-icon-set-up"></i>已认证营业执照</div>
            <div class="authenticate"><i class="el-icon-s-custom"></i>已认证手机号</div>
            <div class="form-title-label" v-if="detail.isStateOwned>0">国有</div>
            <div class="form-title-label"  v-if="detail.isDomesticInvestment >0">内资</div>
            <div class="form-title-label"  v-if="detail.isGoOnTheMarket>0">上市</div>
          </div>
          <div class="other-block" v-if="detail.natureText">甘肃酒泉&nbsp;·&nbsp;{{detail.enterpriseTypeText}}&nbsp;·&nbsp;{{detail.scaleVo.data}}&nbsp;·&nbsp;{{detail.natureText}}</div>
          <div class="other-block" v-else>甘肃酒泉&nbsp;·&nbsp;{{detail.enterpriseTypeText}}&nbsp;·&nbsp;{{detail.scaleVo.data}}&nbsp;·&nbsp;暂无企业性质</div>
        </div>
      </div>
    </div>
    <div class="page-content">
      <div class="introduce-block block" v-if="imgList && imgList.length>0">
        <div class="introduce-item">
          <div class="title">企业简介</div>
          <div class="introduce" v-html="detail.enterpriseIntroduction" v-if="detail.enterpriseIntroduction"></div>
          <div class="introduce" v-else>暂无简介</div>
        </div>
        <template>
          <div class="introduce-photo" v-loading="imgLoading">
            <el-carousel >
              <el-carousel-item v-for="(item) in imgList" :key="item.id">
                <img :src="item.imgUrl" alt="" class="introduce-photo">
              </el-carousel-item>
            </el-carousel>
          </div>
        </template>
      </div>
      <div class="introduce-block1 block" v-else>
        <div class="introduce-item">
          <div class="title">企业简介</div>
          <div class="introduce" v-html="detail.enterpriseIntroduction" v-if="detail.enterpriseIntroduction"></div>
          <div class="introduce" v-else>暂无简介</div>
        </div>
      </div>
      <div class="block position-block">
        <div class="block-title">
          <div class="line"></div>
          <div class="title-item">
            <div class="title">招聘职位</div>
          </div>
        </div>
      </div>
     <template v-if="position.length>0">
       <div class="position-block block" v-loading="positionLoading">
         <router-link :to="{name:'positionDetail',query:{jobType:item.jobType,id:item.id}}" v-for="item in position" :key="item.id" class="position-item">
           <div class="name-block">
             <div class="name">{{item.jobTitle}}</div>
             <div class="wage" v-if="item.minSalary">{{item.minSalary}}-{{item.maxSalary}}元</div>
             <div class="wage" v-else>面议</div>
           </div>
           <div class="other">{{item.jobAddress}}&nbsp;/&nbsp;{{item.expRequireText}}</div>
           <!--          <div class="label-block">-->
           <!--&lt;!&ndash;            <div v-for="label in item.label" class="label-item">{{label}}</div>&ndash;&gt;-->
           <!--          </div>-->
           <div class="label-block">
             <div class="label-item">{{item.minEducationText}} </div>
           </div>
         </router-link>
       </div>
     </template>
      <el-empty v-else></el-empty>
      <div class="block position-block">
        <div class="block-title">
          <div class="line"></div>
          <div class="title-item">
            <div class="title">地址或联系信息</div>
          </div>
        </div>
      </div>
      <div class="company-info-block info">
        <div class="info-item">
          <div class="label-block">
            <div class="iconfont icon-shouhuodizhi"></div>
            <div class="label">联系地址</div>
          </div>
          <div class="info-content" v-if="detail.dom&&detail.dom!=='null'">{{ detail.dom }}</div>
          <div class="info-content" v-else>暂无</div>
        </div>
        <div class="info-item">
          <div class="label-block">
            <div class="iconfont icon-youxiang"></div>
            <div class="label">企业邮箱</div>
          </div>
          <div class="info-content">未公布</div>
        </div>
        <div class="info-item">
          <div class="label-block">
            <div class="iconfont icon-dianhuatianchong"></div>
            <div class="label">公司电话</div>
          </div>
          <div class="info-content" v-if="detail.legalPersonMobileNumber">{{detail.legalPersonMobileNumber}}</div>
          <div class="info-content" v-else>暂无</div>
        </div>
        <div class="info-item">
          <div class="label-block">
            <div class="iconfont icon-diannao"></div>
            <div class="label">官网</div>
          </div>
          <div class="info-content">未公布</div>
        </div>
      </div>
      <div class="block position-block">
        <div class="block-title">
          <div class="line"></div>
          <div class="title-item">
            <div class="title">工商信息</div>
          </div>
        </div>
      </div>
      <div class="company-info-block block">
        <div class="company-block">
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-mingcheng"></div>
              <div class="label">企业全称</div>
            </div>
            <div class="info-content" v-if="detail.enterpriseName">{{detail.enterpriseName}}</div>
            <div class="info-content" v-else>暂无</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-shijian"></div>
              <div class="label">成立时间</div>
            </div>
            <div class="info-content" v-if="detail.estdate">{{detail.estdate}}</div>
            <div v-else class="label">暂无数据</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-qitazibenxingxiangmu"></div>
              <div class="label">注册资本</div>
            </div>
            <div class="info-content" v-if="detail.regcap">{{detail.regcap}}万</div>
            <div v-else class="label">暂无数据</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-farendaibiao"></div>
              <div class="label">法人代表</div>
            </div>
            <div class="info-content" v-if="detail.legalPersonName">{{detail.legalPersonName}}</div>
            <div class="info-content" v-else>暂无</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-shouhuodizhi"></div>
              <div class="label">注册地址</div>
            </div>
            <div class="info-content" v-if="detail.enterpriseAddress">{{ detail.enterpriseAddress }}</div>
            <div class="info-content" v-else>暂无地址</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-tongyishehuixinyongdaima"></div>
              <div class="label">统一信用代码</div>
            </div>
            <div class="info-content" v-if="detail.erterpriseIdNum">{{detail.erterpriseIdNum}}</div>
            <div class="info-content" v-else>暂无</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-xingye"></div>
              <div class="label">所属行业</div>
            </div>
            <div class="info-content" v-if="detail.enterpriseTypeText">{{detail.enterpriseTypeText}}</div>
            <div v-else class="label">暂无数据</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-suozaidi"></div>
              <div class="label">所在地</div>
            </div>
            <div class="info-content">酒泉</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-register"></div>
              <div class="label">登记机关</div>
            </div>
            <div class="info-content">暂无</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-baozhangqixian_huaban1"></div>
              <div class="label">营业期限</div>
            </div>
            <div class="info-content">长期</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-leixing"></div>
              <div class="label">企业类型</div>
            </div>
            <div class="info-content">有限责任公司</div>
          </div>
          <div class="info-item">
            <div class="label-block">
              <div class="iconfont icon-yewuzhuangtai"></div>
              <div class="label">经营状态</div>
            </div>
            <div class="info-content">存续</div>
          </div>
        </div>
        <div class="info-item full">
          <div class="label-block">
            <div class="iconfont icon-xiangmujingyingxinxichaxun"></div>
            <div class="label">经营范围</div>
          </div>
          <div class="info-content" v-if="detail.businessScope">{{detail.businessScope}}</div>
          <div class="info-content" v-else>暂无数据</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Tools from "@/components/Tools/Tools";
import {insertLookMeApi} from "@/api/attention";
import {getEnterpriseByIdApi, getMyPublishByFairApi} from "@/api/company";
import {mapGetters} from "vuex";
export default {
  name: "company",
  components:{Tools},
  data(){
    return{
      detail:{
        logoUrl:'',
        comName:'',
        follow:'',
        enterpriseName:'',
        scaleVo:{
          data:''
        },
        enterpriseIntroduction:'',
        legalPersonMobileNumber:'',
        estdate:'',
        regcap:'',
        legalPersonName:'',
        erterpriseIdNum:'',
        businessScope:'',
        isStateOwned:'',
        isDomesticInvestment:'',
        isGoOnTheMarket:''
      },

      imgLoading:false,
      imgList:[],

      positionLoading:false,
      position:[],
      follow:0
    }
  },
  methods:{
    addLookMe(){
      if(this.user)
      {
        const loading = this.$loading({text: '关注中'})
        insertLookMeApi({eid:this.id,userType:1,lookMeType:2,state:2}).then((res)=>{
          loading.close()
          this.$message.success('关注成功')
          this.getEnterpriseDetails()
        }).finally(()=>{
          loading.close()
        })
      }

    },
    insertLookMe(){
      if(this.user)
      {
        const loading = this.$loading({text: '取消关注中'})
        insertLookMeApi({eid:this.id,userType:1,lookMeType:2,state:1}).then((res)=>{
          loading.close()
          this.$message.success('取消关注成功')
          this.getEnterpriseDetails()
        }).finally(()=>{
          loading.close()
        })
      }

    },
    lookMe(){
      if(this.user)
      {
        insertLookMeApi({eid:this.id,userType:1,lookMeType:1,state:2})
      }

    },
    getEnterpriseDetails(){
      this.imgLoading=true
      getEnterpriseByIdApi({id:this.id}).then((res)=>{
        if(res==null){
          this.$router.push({
            path: '/404'
          })
        }
        else {
          this.detail=res
          this.imgList=res.albumModelList
        }

      }).finally(()=>{
        this.imgLoading=false
      })
    },
    getMyPublishByFairApi(){
      this.positionLoading=true
      getMyPublishByFairApi({page:1,limit:10,comId:this.id}).then((res)=>{
        this.position=res
      }).finally(()=>{
        this.positionLoading=false
      })
    },
  },
  mounted() {
    this.utils.createParams(this,this.$route.query);
    this.lookMe()
    this.getEnterpriseDetails()
    this.getMyPublishByFairApi()
  },
  computed: {
    ...mapGetters(['user'])
  }
}
</script>
<style scoped lang="scss">
.content{
  display: flex;
  flex-direction: column;
  align-items: center;
  .top-info-block{
    width: 100%;
    height: 180px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    background: url("~@/assets/images/company/top-bg.png") no-repeat center;
    background-size: 100%;
    .info-content{
      width: $contentWidth;
      display: flex;
      flex-direction: row;
      align-items: center;
      .company-photo{
        width: 70px;
        height: 70px;
        border-radius: 3px;
        margin-right: 20px;
      }
      .info-block{
        width: calc(100% - 90px);
        display: flex;
        flex-direction: column;
        .name-block{
          display: flex;
          flex-direction: row;
          align-items: center;
          .name{
            font-size: 24px;
            color: #fff;
            font-weight: bold;
            margin-right: 20px;

          }
          .attention-btn{
            width: 60px;
            height: 25px;
            background: $orange;
            color: #fff;
            font-size: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 20px;
            border-radius: 20px;
            cursor: pointer;
          }
          .shielding{
            font-size: 12px;
            color: #fff;
            cursor: pointer;
          }
        }
        .authentication{
          display: flex;
          flex-direction: row;
          margin-top: 15px;

          .authenticate{
            color: #e4e4e4;
            font-size: 14px;
            align-items: center;
            height: 20px;
            border-radius: 2px;
            margin-right: 20px;
            .el-icon-set-up{
              color: #FF8888;
              margin-right: 8px;
              font-size: 20px;
            }
            .el-icon-s-custom{
              margin-right: 8px;
              font-size: 20px;
              color: #79DEA2;
            }
          }
          .form-title-label{
            width: 60px;
            height: 25px;
            border: 1px solid  #fff;
            color: #fff;
            text-align: center;
            border-radius: 5px;
            margin-right: 10px;
          }
        }
        .other-block{
          font-size: 14px;
          color: #fff;
          margin-top: 16px;
        }
      }
    }
  }
  .page-content{
    width: $contentWidth;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    .block{
      display: flex;
    }
    .introduce-block{
      flex-direction: row;
      padding: 30px;
      background: #fff;
      border-radius: 10px;
      .introduce-photo{
        width: 380px;
        border-radius: 10px;
        height: 300px;
      }
      .introduce-item{
        width: calc(100% - 400px);
        .title{
          font-size: 22px;
          font-weight: bold;
        }
        .introduce{
          margin-right: 20px;
          font-size: 16px;
          margin-top: 8px;
          line-height: 2.2;
        }
      }
    }
    .introduce-block1{
      flex-direction: row;
      padding: 30px;
      background: #fff;
      border-radius: 10px;
      .introduce-item{
        width: 100%;
        .title{
          font-size: 22px;
          font-weight: bold;
        }
        .introduce{
          margin-right: 20px;
          font-size: 16px;
          margin-top: 8px;
          line-height: 2.2;
        }
      }
    }
    .block-title {
      width:$contentWidth;
      height: 70px;
      display: flex;
      flex-direction: row;
      align-items: center;
      //padding: 0 30px;
      border-radius: 5px;

      .line {
        height: 23px;
        width: 10px;
        background: $red;
        border-radius: 20px;
        margin-right: 10px;
      }

      .title-item{
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        .title {
          font-weight: bold;
          font-size: 20px;
          color: $orange;
        }
        .more{
          color: $orange;
          font-size: 14px;
        }
      }
    }
    .position-block{
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      .position-item{
        width: calc((100% - 40px)/3);
        margin-right: 20px;
        background: #fff;
        border-radius: 10px;
        padding:15px;
        margin-bottom: 20px;
        display: flex;
        flex-direction: column;
        cursor: pointer;
        .name-block{
          font-size: 20px;
          font-weight: bold;
          display: flex;
          flex-direction: row;
          align-items: center;
          .name{
            font-size: 18px;
            flex-grow: 1;
            width: 18px;
            height: 28px;
            overflow: hidden;
          }
          .wage{
            flex-grow: 0;
            color: $orange;
            font-size: 17px;
          }
        }
        .other{
          color: $darkGray;
          font-size: 14px;
          margin-top: 10px;
        }
        .label-block{
          margin-top: 10px;
          display: flex;
          flex-direction: row;
          flex-wrap: wrap;
          width: 100%;
          .label-item{
            margin-right: 8px;
            margin-bottom: 8px;
            padding: 2px 6px;
            border-radius: 4px;
            font-size: 14px;
            color:$darkGray;
            background: $lightGray;
          }
        }
      }
      .position-item:nth-child(3n){
        margin-right: 0;
      }
    }
    .company-info-block.info{
      background: #fff;
      border-radius: 10px;
      padding: 30px;
      display: flex;
      flex-direction: row;
      .info-item{
        width: 25%;
        display: flex;
        flex-direction: column;
        margin-top: 10px;
        .label-block{
          display: flex;
          flex-direction: row;
          align-items: flex-end;
          .iconfont{
            color: $orange;
            margin-right: 5px;
            font-size:22px ;
          }
          .label{
            font-size: 16px;
            color: #4d4d4d;
          }
        }
        .info-content{
          margin-top: 10px;
          font-weight: bold;
          width: 80%;
        }
      }
      .info-item:last-child{
        margin-right: 0;
      }
      .info-item.full{
        margin-top: 20px;
      }
    }
    .company-info-block{
      background: #fff;
      border-radius: 10px;
      padding: 30px;
      display: flex;
      flex-direction: column;
      margin-bottom: 30px;
      .company-block{
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-around;
        justify-items: center;

        .info-item{
          width: 25%;
          display: flex;
          flex-direction: column;
          margin-top: 30px;
          .label-block{
            display: flex;
            flex-direction: row;
            align-items: flex-end;
            .iconfont{
              color: $orange;
              margin-right: 5px;
              font-size:22px ;
            }
            .label{
              font-size: 16px;
              color: #4d4d4d;
            }
          }
          .info-content{
            margin-top: 10px;
            font-weight: bold;
          }
        }
      }
      .info-item.full{
        margin-top: 30px;
        .label-block{
          display: flex;
          flex-direction: row;
          align-items: flex-end;
          .iconfont{
            color: $orange;
            margin-right: 5px;
            font-size:22px ;
          }
          .label{
            font-size: 16px;
            color: #4d4d4d;
          }
        }
        .info-content{
          margin-top: 20px;
          font-weight: bold;
        }
      }
    }
  }
}
</style>
<style lang="scss" >
.el-carousel__indicators--horizontal{
  left: 15% !important;
  transform: translateX(-10%) !important;
}
</style>

